/**
 * @projectName study-note
 * @package Iterator
 * @className Iterator.ConcreteGather
 */
package Iterator;

import java.util.ArrayList;
import java.util.List;

/**
 * ConcreteGather
 * @description 具体聚集类
 * @author answer_wx
 * @date 2022/7/4 11:01
 * @version 1.0
 */
public class ConcreteGather<T> extends AbstractGather {
    private List<T> lists = new ArrayList<>();

    @Override
    public Iterator<T> createIterator() {
        return new ConcreteIterator<T>(this);
    }

    public Iterator<T> createIteratorDesc() {
        return new ConcreteIteratorDesc<T>(this);
    }

    public int count() {
        return lists.size();
    }

    public void add(int index, T t) {
        lists.add(index, t);
    }

    public T get(int index) {
        return lists.get(index);
    }
}